﻿@{
    ViewBag.Title = "材料采购合同登记-编辑";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<link href="~/Content/css/ContractRegistrationAdd.css" rel="stylesheet" />
<script type="text/javascript">
    $(function () {
        Index.init();
    });
    
    


    var Index = {
        jsonData: null,
        init: function () {
            with (Index) {
                initControl();
            }
        },
        initControl: function () {
            //材料分类
            $("#CLFL").bindSelect({
                url: "/Purchase/MaterialPurchase/GetMaterialCategories",
                id: "MaterialNO",
                text: "MaterialNOName"
            });
            //产地
            $("#CGCD").bindSelect({
                url: "/Purchase/MaterialPurchase/GetFProductionTypies?FClassNO=40",
                id: "FTypeNO",
                text: "FTypeNOName"
            });
            //到站
            $("#CGDZ").bindSelect({
                url: "/Purchase/MaterialPurchase/GetFProductionTypies?FClassNO=39",
                id: "FTypeNO",
                text: "FTypeNOName"
            });
            //采购分类
            $("#CGCGFL").bindSelect({
                url: "/Purchase/MaterialPurchase/GetFProductionTypies?FClassNO=38",
                id: "FTypeNO",
                text: "FTypeNOName"
            });
            //采购方式
            $("#CGCGFS").bindSelect({
                url: "/Purchase/MaterialPurchase/GetFProductionTypies?FClassNO=37",
                id: "FTypeNO",
                text: "FTypeNOName"
            });
            //用途
            $("#CGYT").bindSelect({
                url: "/Purchase/MaterialPurchase/GetFProductionTypies?FClassNO=41",
                id: "FTypeNO",
                text: "FTypeNOName"
            });
            //供货单位
            $("#CGGHDW").bindSelect({
                url: "/Purchase/MaterialPurchase/GetSupplierInformationies?idx=0",
                id: "UnitNO",
                text: "UnitNOName"
            });
            //分流
            $("#CGLX").bindSelect({
                url: "/Purchase/MaterialPurchase/GetSupplierInformationies?idx=1",
                id: "UnitNO",
                text: "UnitNOName"
            });
            $.request("postData") && (Index.jsonData = JSON.parse(decodeURIComponent($.request("postData"))));
            //修改
            Index.jsonData && (function () {
                
                var cols = "ID,CLFL,CGHTRQ,CGHTBH,CGCLPH,CGCGFS,CGCLBZBH,CGCLTSYQ,CGCGFL,CGDZ,CGCD,CGLX,CGGHDW,CGYT,CGDHSL,CGCGDJ,CGDZDJ,CGBHSM".split(",");
                
                cols.forEach(function (col) {
                    $("#{0}".format(col)).val(Index.jsonData[col]);
                });
                var cs = "CGCLGG_T,CGCLGG_H,CGCLGG_W".split(","), vals = Index.jsonData["CGCLGG"].split("x");

                $.each(cs, function (i,item) {
                    $("#{0}".format(item)).val(vals[i]);
                });

                $('select').bindSelect();
            })();
            //新增
            Index.jsonData || (function (i, item) {
                
            })();
            //打开材料选择界面
            $("#butnGoPartNumbers").on("click", function () {
                var url = "/Purchase/MaterialPurchase/ContractRegistrationMaterialSelect";

                $.modalOpen({
                    id: "dlgContractRegistrationMaterialSelect",
                    url: url,
                    width: "720px",
                    height: "480px",
                    title: "材料选择",
                    close: true,
                    callBack: function (id, isCancel) {
                        !isCancel && (function () {
                            var cols = "MaterialNO,MaterialCode".split(",");

                            var dests = "CLFL,CGCLPH".split(",");

                            var rowData = {};

                            var cc = parent.parent.$("#{0}".format(id)).find("iframe").contents();
                            
                            $.each(cols, function (i,item) {
                                $("#{0}".format(dests[i])).val(cc.find("#{0}1".format(item)).val());
                            });
                            
                            var sizes = cc.find("#MaterialSizes1").val().split("x"), ts = "T,H,W".split(",");

                            $.each(ts,function (i,item) {
                                $("#CGCLGG_{0}".format(item)).val($.trim(sizes[i]));
                            })

                            $('select').bindSelect();
                        })();
                    }
                });
            });

            $("[date-control]").on("click", function () {
                WdatePicker({ dateFmt: 'yyyy.MM', minDate: '2000-1', maxDate: '2050-12' });
            });

            $("[date-control]").val(new Date().format("yyyy.MM"));
        }
    };
</script>

<div class="layout" id="layout">
    <ul class="form_list">
        <li class="form_item form_item_1">
            <label>
                合同日期
            </label>
            <div class="input_c">
                <input id="CGHTRQ" name="" placeholder="" type="text" class="form-control required" date-control />
                <input id="ID" name="" type="hidden" class="form-control required"/>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_1">
            <label>合同编号</label>
            <div class="input_c">
                <input id="CGHTBH" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>材料分类</label>
            <div class="input_c">
                <select id="CLFL" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>材料牌号</label>
            <div class="input_c input_c_2">
                <input id="CGCLPH" name="" placeholder="" type="text" class="form-control required"/>
            </div>
            <div class="form_item_aftern">
                <button id="butnGoPartNumbers" class="butn_details glyphicon  glyphicon-search"></button>
            </div>
        </li>
        <li class="form_item form_item_2">
            <label>材料规格</label>
            <div class="input_c input_three">
                <input id="CGCLGG_T" name="" type="text" class="form-control required" />X
                <input id="CGCLGG_H" name="" type="text" class="form-control required" />X
                <input id="CGCLGG_W" name="" type="text" class="form-control required" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>采购方式</label>
            <div class="input_c input_c_2">
                <select id="CGCGFS" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>材料标准</label>
            <div class="input_c">
                <input id="CGCLBZBH" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>采购分类</label>
            <div class="input_c input_c_2">
                <select id="CGCGFL" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_3">
            <label>特殊要求</label>
            <div class="input_c">
                <input id="CGCLTSYQ" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>到站</label>
            <div class="input_c input_c_3">
                <select id="CGDZ" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>产地</label>
            <div class="input_c input_c_3">
                <select id="CGCD" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>流向</label>
            <div class="input_c input_c_3">
                <select id="CGLX" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>送货单位</label>
            <div class="input_c input_c_3">
                <select id="CGGHDW" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li class="form_item form_item_2">
            <label>用途</label>
            <div class="input_c input_c_3">
                <select id="CGYT" name="" class="form-control">
                    <option value="">请选择</option>
                </select>
            </div>
            <div class="form_item_after">*</div>
        </li>
        <li clear></li>
    </ul>

    <ul class="form_list">
        <li class="form_item form_item_1">
            <label>
                订货数量
            </label>
            <div class="input_c">
                <input id="CGDHSL" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_aftern">吨</div>
        </li>
        <li class="form_item form_item_2">
            <label>订货单价</label>
            <div class="input_c">
                <input id="CGCGDJ" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_aftern">元</div>
        </li>
        <li class="form_item form_item_2">
            <label>订货单价</label>
            <div class="input_c">
                <input id="CGDZDJ" name="" placeholder="" type="text" class="form-control required" />
            </div>
            <div class="form_item_aftern">元</div>
        </li>
        <li class="form_item form_item_1">
            <label>备注</label>
            <div class="input_c">
                <input id="CGBHSM" name="" placeholder="" type="text" class="form-control required" />
            </div>
        </li>
        <li clear></li>
    </ul>
</div>

